Note: This tutorial assumes that you have completed the previous tutorials: Writing a Stiffness Controller (c++),(python).
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Running the Controller

Description: Explains how to how to run a force controlled trajectory.

Keywords: force, compliance, impedance, stiffness, controller, pr2 arms

Tutorial Level: BEGINNER

Next Tutorial: Writing a Force Controller (c++) (python)

If you have not already, you must first download the ee_cart_imped stack.

Updating the Controller and Action Files

Since the controller and action are not kept within the ROS stacks, you may want to update them manually to ensure you have the most recent version:

roscd ee_cart_imped
svn update

Compiling

If you have not yet done so, rosmake the controller:

rosmake ee_cart_imped_control

Now rosmake the package you made in the previous tutorial (if using the electric release, the package has no direct dependency on ee_cart_imped_control which is why they must be made separately):

rosmake ee_cart_imped_tutorial

This will compile the ee_cart_imped_msgs, and ee_cart_imped_action packages. If you went through the previous tutorial in C++, this will compile the code you wrote in that tutorial as well.

Starting the Controller and Action Server

You must wait for the controller build to complete before starting the robot or simulator!

Once the build is complete, if you are working in simulation, open a new shell and run

roslaunch pr2_gazebo pr2_empty_world.launch

If you are working on the PR2, restart the robot so that it will recognize the new controller:

robot start

(If running cturtle, you need to use the -e option.) Note that the first time the ee_cart_imped_control package is built, you must re-start the robot or simulator after the build completes. If you have already built the controller, however, and made no changes since the time of the build, it is not necessary to re-start the robot or simulator. In general use, you will compile the ee_cart_imped_control package once on download, at which time the robot or simulator must be re-started. After that, you need not re-start the robot or simulator when running the controller.

Once the simulator is up or the robot is restarted, in a new shell type

roslaunch ee_cart_imped_action r_arm_cart_imped_action.launch

This stops the usual controller for the right arm and starts the ee_cart_imped controller and action server for the right arm. To use the controller for the left arm, look at the ee_cart_imped_action/launch/l_arm_cart_imped.launch file. To launch the controller for both arms, you can use the ee_cart_imped_launch/launch/ee_cart_imped_action.launch file. If you got the error

ERROR: cannot launch node of type [ee_cart_imped_action/ee_cart_imped_action]: can't locate node [ee_cart_imped_action] in package [ee_cart_imped_action]

or the robot halted when you launched it, you likely did not wait for the build to complete before starting the robot. Try re-starting the robot and launching again. If the trouble persists, see the troubleshooting page for common errors that could lead to the problem.

The ee_cart_imped controller is now running in the right arm. At present, the controller is attempting to hold the end effector at a constant Cartesian point. If you are working with the PR2, you can test if the new controller is indeed controlling the right arm by manipulating the arm joints without moving the end effector. Unlike under the standard controller (which should still be running on the left arm for comparison), so long as the end effector does not move, there should not be much resistance to moving the other joints:

Running the Trajectory

Now you can try running the example we created. Pull up a new terminal. If you did the previous tutorial in C++, type:

rosrun ee_cart_imped_tutorial stiffness_control

If you did the previous tutorial in python, type:

rosrun ee_cart_imped_tutorial stiffness_control.py

You should see the trajectory execute.

With this controller, the last point will be held with the desired force or stiffness. In this case, this means that there will still be a light stiffness in the x direction. This should be very noticeable if you attempt to move the PR2 gripper. It will be easy to move it in the x direction (towards or away from the robot), but hard to move in any other direction or to turn.

Force Control

Now that we have written and run a stiffness controller, we can use the ee_cart_imped stack to also run a force-controlled trajectory (c++), (python).

Wiki: ee_cart_imped/Tutorials/Running the Controller (last edited 2013-02-01 23:40:23 by JennyBarry)